"""
ASGI config for wx_demo project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wx_demo.settings')
#
# application = get_asgi_application()

import os

from django.core.wsgi import get_wsgi_application
from channels.routing import ProtocolTypeRouter, URLRouter

from . import routings

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wx_demo.settings")

# application = get_wsgi_application()
# 支持http和websocket
application = ProtocolTypeRouter({
    "http": get_wsgi_application(),  # 默认http,自动找urls.py和views.py
    "websocket": URLRouter(routings.websocket_urlpatterns),  # 因为django没有自动帮我们创建urls.py和views.py,所以我们要自己创建routings(urls),consumers(views)
})
